* Master dofile for MW *project.

/*=========================================================================
                        1: Import Data
===========================================================================*/
* Import data - ENH
do Code/Import/import_enh_data.do 
do Code/Import/import_mw.do 
do Code/Import/import_rr_PIBTotal.do 
do Code/Import/import__rr_DepartamentoCapital.do 
do Code/Import/import_rr_ValorAgregado.do 

/*=========================================================================
                        2: Clean Data
===========================================================================*/

do Code/Clean/clean_enh.do 
do Code/Clean/clean_prices.do 
do Code/Clean/clean_mw.do 
do Code/Clean/merge_ocupados.do 
do Code/Clean/merge_desocupados.do 
do Code/Clean/merge_inactivos.do 
do Code/Clean/append_labor_force.do 
do Code/Clean/clean_rr_ValorAgregado.do 
do Code/Clean/clean_rr_PIBTotal.do 
do Code/Clean/clean_rr_DepartamentoCapital.do 

/*=========================================================================
                        3: Build source datasets
===========================================================================*/

* Build variables for estimation. I build them with the ocupados dataset but they apply to employment regressions as well.
do Code/Est/build_var_ocupados.do 
* Build employment variables
do Code/Est/build_var_employment.do 
* Create dataset with bites
do Code/Est/bites.do 



/*=========================================================================
                        4: Estimation programs
===========================================================================*/

* These programs are called within the estimations, but not executed in the master file
* 1. Program to choose a sample 
do Code/Est/sample_choice.do 
* 2. Program to build minimum wage measures and trends
do Code/Est/build_mw_measures.do 
* 3. Program to build treatment variables
do Code/Est/build_treatment.do 
* 4. Program to do bs estimation
relies_on "`master'/Code/Est/confirmedrun.do" 
* 5 Program to export results
relies_on "`master'/Code/Est/export_rif.do" 

/*=========================================================================
                        5: Paper 
===========================================================================*/

* Figure 1  
do Code/Fig/density.do 
* Figure 2  
do Code/Doc/tosubmit2/mw_evolution.do 
* Table 1  
do Code/Doc/tosubmit2/tab1.do 
* Table 2  
do Code/Doc/tosubmit2/tab2.do 
* Figure 3  
do Code/Fig/bitegraph.do 

* Estimations for figure 4 and table 3
do Code/Est/regressions_formal_bite_industry_ccity.do   
do Code/Est/regressions_formal_bite_industry_ccity_PIB_rezago.do   

* Figure 4
do Code/Doc/tosubmit2/formal_graph.do   

* Table 3
do Code/Doc/tosubmit3/formal.do   

* Estimations for figure 5
* Calculate counterfactuals
do Code/Doc/tosubmit2/scale2.do    
* Figure 5
do Code/Doc/tosubmit2/scale_graph_formal.do    
*/
* Estimations for figure 6
do Code/Est/regressions_informal_edom_bite_industry_ccity.do    
do Code/est/regressions_informal_edom_ebite_industry_ccity.do    
do Code/Est/regressions_informal_edom_bite_industry_ccity_PIB_rezago.do    
do Code/est/regressions_informal_edom_ebite_industry_ccity_PIB_rezago.do    
* Figure 6
do Code/Doc/tosubmit2/informal_graph.do    
do Code/Doc/tosubmit2/informal_ebite_graph.do    

* Table 4

do Code/Doc/tosubmit3/informal.do    

* Estimations for figure 7
do Code/Est/regressions_pfi_informal_edom_bite_industry_ccity.do    
* Figure 7
do Code/Doc/tosubmit2/pfi_graph.do 

* Estimations for table 5
do Code/Est/emp/regressions_formal_employment_industry_nce_ccity.do    
do Code/Est/emp/regressions_formal_horas_industry_nce_ccity.do    
do Code/Est/emp/regressions_informal_edom_employment_industry_nce_ccity.do     //s16
do Code/Est/emp/regressions_informal_edom_horas_industry_nce_ccity.do    

* Table 5
do Code/Doc/tosubmit2/emp.do    

* Appendix A
* Checks hor many workers may be misclassified
do Code/Est/misclassification_check.do    

* Appendix B


* Estimation for figure B1
do Code/Est/regressions_formal_bite_industry_ccity.do    
do Code/Est/regressions_formal_ebite_industry_ccity.do    
do Code/Est/regressions_formal_med_industry_ccity.do    
do Code/Est/regressions_formal_ebite_industry_ccity_robustness.do    
do Code/Est/regressions_formal_ebite_industry_ccity_robustness.do    
do Code/Est/regressions_formal_gap_industry_ccity.do    

* Figure B1
do Code/Doc/tosubmit2/formal_measures_gap.do    
do Code/Doc/tosubmit2/formal_ebite_sens_graph.do    

* Estimation for figure B2
do Code/Est/robustness_ej6.do    

* Figure B2
do Code/Doc/tosubmit2/formal_rob_graph.do    

* Figure B3

do Code/Doc/tosubmit2/formal_den_rob_graph.do    


*Estimation for figure B4
do Code/Est/robustness_ej3.do    
do Code/Est/robustness_ej3_informal.do    

* Figure B4

do Code/Doc/tosubmit2/robustness_end_of_year_single.do    
do Code/Doc/tosubmit2/robustness_end_of_year_single_informal.do    


* Estimation for figure B5
do Code/Est/regressions_informal_edom_bite_industry_ccity.do    
do Code/est/regressions_informal_edom_ebite_industry_ccity.do    
do Code/Est/regressions_informal_med_industry_ccity.do    
do Code/Est/regressions_informal_ebite_industry_ccity_robustness.do    

* Figure B5
do Code/Doc/tosubmit2/informal_measures_gap.do    
do Code/Doc/tosubmit2/informal_ebite_sens_graph.do    

* Estimation for figure B6
do Code/Est/robustness_ej6_informal.do    

* Figure B6
do Code/Doc/tosubmit2/informal_rob_graph.do    

* Estimation for figure B7

do Code/Est/regressions_pfi2_informal_edom_bite_industry_ccity.do   

* Figure B7

do Code/Doc/tosubmit2/pfi_graph_city_level.do    


* Table B1
do Code/Est/regressions_formal_bite_industry_ccity_ciudades.do   
do Code/Doc/tosubmit2/formal_cities.do   


* Table B2
do Code/Est/regressions_informal_edom_ebite_industry_ccity_ciudades.do   
do Code/Doc/tosubmit2/informal_cities.do   

* Estimations for table B3
do Code/Est/joint_coef_bs.do   
do Code/Est/joint_coef_bs_ebite.do   
* Table B3
do Code/Est/joint_coef_bs_tests.do   

* Table B4
do Code/Est/emp/regressions_formal_employment_industry_nce_ccity_defl_nac.do   
do Code/Est/emp/regressions_formal_horas_industry_nce_ccity_defl_nac.do   
do Code/Est/emp/regressions_informal_edom_employment_industry_nce_ccity_defl_nac.do   
do Code/Est/emp/regressions_informal_edom_horas_industry_nce_ccity_defl_nac.do   
do Code/Doc/tosubmit2/emp_defl_nac.do   






